﻿using System.Windows;
using System.Windows.Controls;
using YY.Admin.Core.FluentValidation;
using YY.Admin.ViewModels.SysManage;

namespace YY.Admin.Views.SysManage
{
    /// <summary>
    /// Interaction logic for UserEditDialog.xaml
    /// </summary>
    public partial class UserEditDialogView : UserControl
    {
        public UserEditDialogView()
        {
            InitializeComponent();
            FluentValidationHelper.Attach(RootPanel, typeof(UserEditDialogViewModel));
        }

        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            var vm = (UserEditDialogViewModel)DataContext;
            bool valid = FluentValidationHelper.ValidateAll(RootPanel, vm.SysUser!, vm.SysUserValidator);
            if (valid)
            {
                _ = vm.SaveUserAsync();
            }
        }
    }
}
